package parameter.soil;
import dao.MyDAO;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.GridBagLayout;

import javax.swing.JLabel;

import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Color;
import java.awt.SystemColor;
import java.awt.Font;

import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import javax.swing.AbstractAction;
import javax.swing.Action;

public class actImpsoil3 extends JFrame {
	/**
	 * 
	 * @author huanghongtao
	 */
	private JPanel contentPane;
	private JTextField textField;
	private JTextField txtCm;
	private JTextField txtCmcm;
	private JTextField txtCm_2;
	private JTextField textField_1;
	private JTextField txtCmcm_1;
	private final Action action = new SwingAction();
	public Soil soil=new Soil();
	Connection con=null;
	Statement sql_statement=null;
	String ctrl_model=null;
	int maxId_3;
	ArrayList<String> waterjzsList=new ArrayList();
    ArrayList<String> waterddlList=new ArrayList();
    ArrayList<String> dry_soiljdList=new ArrayList();
	//ArrayList<String> 
    double Of;                              //田间持水量的实数形式
	double Or;                              //残余水量的实数形式
	double Os;                              //饱和水量的实数形式 
	double Hf;                             //土壤基质势的实数形式
	double On;                             //n的实数形式
	double Oa;                             //拟合系数的实数形式
	String filedWater=null;                     //田间持水量的String形式
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					actImpsoil3 frame = new actImpsoil3();
					
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public actImpsoil3() {
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 985, 518);
		contentPane = new JPanel();
		contentPane.setToolTipText("aasa");
		contentPane.setBackground(SystemColor.inactiveCaptionBorder);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		gbl_contentPane.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		//实际蒸腾估算改进方法三参数传感器
		JLabel lblNewLabel = new JLabel("实际蒸腾估算根区加权平均法（土壤水盐传感器）");
		lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel.setForeground(Color.BLACK);
		lblNewLabel.setBackground(Color.BLACK);
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.gridwidth = 11;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 2;
		gbc_lblNewLabel.gridy = 0;
		contentPane.add(lblNewLabel, gbc_lblNewLabel);

		
		try{
			 con =MyDAO.getConnection();        
             sql_statement = con.createStatement();
             String query_1="select * from ctrlzone_dic where id='1'";       //测试数据库            
             String query_2="select max(id) from soil_para3";
             String query_3="select soilWaterjzs from soil_waterjzs";
             String query_5="select distilledWDDL from distilled_wddl";
             String quer_6="select drySoilJD from dry_soiljd";
             ResultSet rs_2=sql_statement.executeQuery(query_1);
             dry_soiljdList.add("请输入以下参数");
             waterjzsList.add("请输入以下参数");
             waterddlList.add("请输入以下参数");
             if(rs_2.next());
             {
            	  ctrl_model=(String)rs_2.getString("name");                  //获得控制块名称
             } 
              rs_2.close();
             ResultSet rs_1=sql_statement.executeQuery(query_2);
             if(rs_1.next()){
            	 maxId_3=(int)rs_1.getInt(1)+1;                           //获的数据库下一条的Id
             }
             System.out.print(maxId_3);
             rs_1.close();
             ResultSet rs_3=sql_statement.executeQuery(query_3);
             while(rs_3.next()){
            	 waterjzsList.add(rs_3.getString(1));                   //获得土壤基质势的List
             } 
             rs_3.close();
             ResultSet rs_5=sql_statement.executeQuery(query_5);
             while(rs_5.next()){
            	 waterddlList.add(rs_5.getString(1));                   //获得蒸馏水电导率的List
             }
             rs_5.close();
             ResultSet rs_6=sql_statement.executeQuery(quer_6);
             while(rs_6.next()){
            	 dry_soiljdList.add(rs_6.getString(1));
             }
             rs_6.close();
             
             
             
             

            /** *//************ 连接数据库并获得控制块 ************/  
	        } catch(java.lang.ClassNotFoundException e1) {
	            //加载JDBC错误,所要用的驱动没有找到
	            System.err.print("ClassNotFoundException");
	            //其他错误
	            System.err.println(e1.getMessage());
	        } catch (SQLException ex) {
	            //显示数据库连接错误或查询错误
	            System.err.println("SQLException: " + ex.getMessage());
	        }catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} 
		
		JLabel label_7 = new JLabel("当前控制区：");
		label_7.setFont(new Font("宋体", Font.BOLD, 15));
		GridBagConstraints gbc_label_7 = new GridBagConstraints();
		gbc_label_7.gridwidth = 2;
		gbc_label_7.insets = new Insets(0, 0, 5, 5);
		gbc_label_7.gridx = 13;
		gbc_label_7.gridy = 1;
		contentPane.add(label_7, gbc_label_7);
		
		JLabel label = new JLabel(ctrl_model);
		label.setFont(new Font("宋体", Font.PLAIN, 13));
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.insets = new Insets(0, 0, 5, 0);
		gbc_label.gridx = 15;
		gbc_label.gridy = 1;
		contentPane.add(label, gbc_label);
		
		JLabel lblNewLabel_1 = new JLabel("土壤参数");
		lblNewLabel_1.setFont(new Font("宋体", Font.PLAIN, 18));
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_1.gridx = 0;
		gbc_lblNewLabel_1.gridy = 2;
		contentPane.add(lblNewLabel_1, gbc_lblNewLabel_1);
		
		JLabel label_1 = new JLabel("请正确输入以下参数！");
		label_1.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_label_1 = new GridBagConstraints();
		gbc_label_1.gridwidth = 2;
		gbc_label_1.insets = new Insets(0, 0, 5, 5);
		gbc_label_1.gridx = 0;
		gbc_label_1.gridy = 3;
		contentPane.add(label_1, gbc_label_1);
		
		JLabel label_2 = new JLabel("    土壤种类 ：");
		label_2.setFont(new Font("宋体", Font.PLAIN, 17));
		GridBagConstraints gbc_label_2 = new GridBagConstraints();
		gbc_label_2.gridwidth = 2;
		gbc_label_2.anchor = GridBagConstraints.WEST;
		gbc_label_2.insets = new Insets(0, 0, 5, 5);
		gbc_label_2.gridx = 1;
		gbc_label_2.gridy = 4;
		contentPane.add(label_2, gbc_label_2);
		

		textField = new JTextField();
		GridBagConstraints gbc_textField = new GridBagConstraints();
		textField.setToolTipText("");
		textField.setText(" ");
		gbc_textField.gridwidth = 6;
		gbc_textField.insets = new Insets(0, 0, 5, 5);
		gbc_textField.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField.gridx = 4;
		gbc_textField.gridy = 4;
		contentPane.add(textField, gbc_textField);
		textField.setColumns(10);	
		
		
		JLabel lblNewLabel_4 = new JLabel("蒸馏水导电率Qd：");
		lblNewLabel_4.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
		gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_4.gridx = 12;
		gbc_lblNewLabel_4.gridy = 4;
		contentPane.add(lblNewLabel_4, gbc_lblNewLabel_4);
		
		String [] waterddl_array=waterddlList.toArray(new String[waterddlList.size()+1]);
		waterddl_array[waterddlList.size()]="自定义";
		JComboBox comboBox_2 = new JComboBox();
		comboBox_2.setEditable(true);
		final DefaultComboBoxModel model_2=new DefaultComboBoxModel(waterddl_array);	
		comboBox_2.setModel(model_2);
		GridBagConstraints gbc_comboBox_2 = new GridBagConstraints();
		gbc_comboBox_2.gridwidth = 2;
		gbc_comboBox_2.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox_2.gridx = 13;
		gbc_comboBox_2.gridy = 4;
		contentPane.add(comboBox_2, gbc_comboBox_2);
		
		JLabel lblNewLabel_8 = new JLabel("（ds/m）");
		GridBagConstraints gbc_lblNewLabel_8 = new GridBagConstraints();
		gbc_lblNewLabel_8.insets = new Insets(0, 0, 5, 0);
		gbc_lblNewLabel_8.gridx = 15;
		gbc_lblNewLabel_8.gridy = 4;
		contentPane.add(lblNewLabel_8, gbc_lblNewLabel_8);
		
		

		JLabel lblNewLabel_2 = new JLabel("    土层下边界参数：");
		lblNewLabel_2.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
		gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_2.fill = GridBagConstraints.VERTICAL;
		gbc_lblNewLabel_2.gridwidth = 2;
		gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_2.gridx = 1;
		gbc_lblNewLabel_2.gridy = 5;
		contentPane.add(lblNewLabel_2, gbc_lblNewLabel_2);
		
		txtCm = new JTextField();
		GridBagConstraints gbc_txtCm = new GridBagConstraints();
		gbc_txtCm.gridwidth = 6;
		gbc_txtCm.insets = new Insets(0, 0, 5, 5);
		gbc_txtCm.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCm.gridx = 4;
		gbc_txtCm.gridy = 5;
		contentPane.add(txtCm, gbc_txtCm);
		txtCm.setColumns(10);
		                
		
		JLabel lblCm = new JLabel("cm");
		lblCm.setFont(new Font("Calibri", Font.BOLD, 15));
		GridBagConstraints gbc_lblCm = new GridBagConstraints();
		gbc_lblCm.anchor = GridBagConstraints.WEST;
		gbc_lblCm.insets = new Insets(0, 0, 5, 5);
		gbc_lblCm.gridx = 10;
		gbc_lblCm.gridy = 5;
		contentPane.add(lblCm, gbc_lblCm);
		
		JLabel lblNewLabel_3 = new JLabel("    饱和水含量θs：");
		lblNewLabel_3.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
		gbc_lblNewLabel_3.gridwidth = 2;
		gbc_lblNewLabel_3.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_3.gridx = 1;
		gbc_lblNewLabel_3.gridy = 6;
		contentPane.add(lblNewLabel_3, gbc_lblNewLabel_3);
		
		txtCmcm = new JTextField();
		txtCmcm.setToolTipText("");
		txtCmcm.setText(" ");
		GridBagConstraints gbc_txtCmcm = new GridBagConstraints();
		gbc_txtCmcm.gridwidth = 6;
		gbc_txtCmcm.insets = new Insets(0, 0, 5, 5);
		gbc_txtCmcm.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCmcm.gridx = 4;
		gbc_txtCmcm.gridy = 6;
		contentPane.add(txtCmcm, gbc_txtCmcm);
		txtCmcm.setColumns(10);
		
		
		JLabel lblCmcm = new JLabel("cm^3/cm^3");
		lblCmcm.setFont(new Font("Cambria", Font.BOLD, 13));
		GridBagConstraints gbc_lblCmcm = new GridBagConstraints();
		gbc_lblCmcm.anchor = GridBagConstraints.WEST;
		gbc_lblCmcm.insets = new Insets(0, 0, 5, 5);
		gbc_lblCmcm.gridx = 10;
		gbc_lblCmcm.gridy = 6;
		contentPane.add(lblCmcm, gbc_lblCmcm);
		
		
		JLabel label_3 = new JLabel("    水力学参数：");
		label_3.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_label_3 = new GridBagConstraints();
		gbc_label_3.gridwidth = 2;
		gbc_label_3.anchor = GridBagConstraints.WEST;
		gbc_label_3.insets = new Insets(0, 0, 5, 5);
		gbc_label_3.gridx = 1;
		gbc_label_3.gridy = 7;
		contentPane.add(label_3, gbc_label_3);
		
		JLabel lbleob = new JLabel("干土介电常数eob：");
		lbleob.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lbleob = new GridBagConstraints();
		gbc_lbleob.anchor = GridBagConstraints.EAST;
		gbc_lbleob.insets = new Insets(0, 0, 5, 5);
		gbc_lbleob.gridx = 12;
		gbc_lbleob.gridy = 7;
		contentPane.add(lbleob, gbc_lbleob);
		
		String [] dry_soiljd_array=dry_soiljdList.toArray(new String[dry_soiljdList.size()+1]);
		dry_soiljd_array[dry_soiljdList.size()]="自定义";
		JComboBox comboBox_1 = new JComboBox();
		comboBox_1.setBackground(Color.WHITE);
		comboBox_1.setEditable(true);
		final DefaultComboBoxModel model_3=new DefaultComboBoxModel(dry_soiljd_array);
		comboBox_1.setModel(model_3);
		GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
		gbc_comboBox_1.gridwidth = 2;
		gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox_1.gridx = 13;
		gbc_comboBox_1.gridy = 7;
		contentPane.add(comboBox_1, gbc_comboBox_1);
		
		
		
		
		JLabel lblNewLabel_5 = new JLabel("请输入以下参数：");
		lblNewLabel_5.setFont(new Font("宋体", Font.PLAIN, 15));
		lblNewLabel_5.setBackground(Color.BLACK);
		lblNewLabel_5.setForeground(Color.BLACK);
		GridBagConstraints gbc_lblNewLabel_5 = new GridBagConstraints();
		gbc_lblNewLabel_5.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel_5.gridwidth = 9;
		gbc_lblNewLabel_5.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_5.gridx = 2;
		gbc_lblNewLabel_5.gridy = 8;
		contentPane.add(lblNewLabel_5, gbc_lblNewLabel_5);
		
		JLabel label_4 = new JLabel("水分特征曲线拟合系数：");
		GridBagConstraints gbc_label_4 = new GridBagConstraints();
		gbc_label_4.anchor = GridBagConstraints.WEST;
		gbc_label_4.gridwidth = 4;
		gbc_label_4.insets = new Insets(0, 0, 5, 5);
		gbc_label_4.gridx = 2;
		gbc_label_4.gridy = 9;
		
		JLabel label_5 = new JLabel("水分特征曲线拟合系数：");
		label_5.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_label_5 = new GridBagConstraints();
		gbc_label_5.gridwidth = 3;
		gbc_label_5.insets = new Insets(0, 0, 5, 5);
		gbc_label_5.gridx = 2;
		gbc_label_5.gridy = 9;
		contentPane.add(label_5, gbc_label_5);
		
		
		txtCm_2 = new JTextField();
		GridBagConstraints gbc_txtCm_2 = new GridBagConstraints();
		gbc_txtCm_2.gridwidth = 4;
		gbc_txtCm_2.insets = new Insets(0, 0, 5, 5);
		gbc_txtCm_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCm_2.gridx = 6;
		gbc_txtCm_2.gridy = 9;
		contentPane.add(txtCm_2, gbc_txtCm_2);
		txtCm_2.setColumns(10);
		soil.setWaterTZQX(txtCm_2.getText());                                 
		
		JLabel lblCm_2 = new JLabel("cm");
		lblCm_2.setFont(new Font("Calibri", Font.BOLD, 15));
		GridBagConstraints gbc_lblCm_2 = new GridBagConstraints();
		gbc_lblCm_2.anchor = GridBagConstraints.WEST;
		gbc_lblCm_2.insets = new Insets(0, 0, 5, 5);
		gbc_lblCm_2.gridx = 10;
		gbc_lblCm_2.gridy = 9;
		contentPane.add(lblCm_2, gbc_lblCm_2);
		
		
		JLabel lblNewLabel_6 = new JLabel("n：");
		GridBagConstraints gbc_lblNewLabel_6 = new GridBagConstraints();
		gbc_lblNewLabel_6.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel_6.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_6.gridx = 2;
		gbc_lblNewLabel_6.gridy = 10;
		
		JLabel lblN = new JLabel("n：");
		lblN.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lblN = new GridBagConstraints();
		gbc_lblN.anchor = GridBagConstraints.WEST;
		gbc_lblN.insets = new Insets(0, 0, 5, 5);
		gbc_lblN.gridx = 2;
		gbc_lblN.gridy = 10;
		contentPane.add(lblN, gbc_lblN);
		
		
		textField_1 = new JTextField();
		GridBagConstraints gbc_textField_1 = new GridBagConstraints();
		gbc_textField_1.gridwidth = 4;
		gbc_textField_1.insets = new Insets(0, 0, 5, 5);
		gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_1.gridx = 6;
		gbc_textField_1.gridy = 10;
		contentPane.add(textField_1, gbc_textField_1);
		textField_1.setColumns(10);
		soil.setSlxPara_n(textField_1.getText());                   
		
		JLabel lblNewLabel_7 = new JLabel("残余含水量θr：");
		GridBagConstraints gbc_lblNewLabel_7 = new GridBagConstraints();
		gbc_lblNewLabel_7.gridwidth = 4;
		gbc_lblNewLabel_7.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel_7.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_7.gridx = 2;
		gbc_lblNewLabel_7.gridy = 11;
		
		JLabel label_6 = new JLabel("残余含水量：");
		label_6.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_label_6 = new GridBagConstraints();
		gbc_label_6.anchor = GridBagConstraints.WEST;
		gbc_label_6.gridwidth = 3;
		gbc_label_6.insets = new Insets(0, 0, 5, 5);
		gbc_label_6.gridx = 2;
		gbc_label_6.gridy = 11;
		contentPane.add(label_6, gbc_label_6);
		
		
		txtCmcm_1 = new JTextField();
		txtCmcm_1.setFont(new Font("宋体", Font.PLAIN, 13));
		GridBagConstraints gbc_txtCmcm_1 = new GridBagConstraints();
		gbc_txtCmcm_1.gridwidth = 4;
		gbc_txtCmcm_1.insets = new Insets(0, 0, 5, 5);
		gbc_txtCmcm_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCmcm_1.gridx = 6;
		gbc_txtCmcm_1.gridy = 11;
		contentPane.add(txtCmcm_1, gbc_txtCmcm_1);
		txtCmcm_1.setColumns(10);
		soil.setRemainWater(txtCmcm_1.getText());                           
		
		JLabel lblCmcm_1 = new JLabel("cm^3/cm^3");
		lblCmcm_1.setFont(new Font("Calibri", Font.BOLD, 13));
		GridBagConstraints gbc_lblCmcm_1 = new GridBagConstraints();
		gbc_lblCmcm_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblCmcm_1.gridx = 10;
		gbc_lblCmcm_1.gridy = 11;
		contentPane.add(lblCmcm_1, gbc_lblCmcm_1);
		
		JLabel lblhf = new JLabel("    田间持水量对应的");
		lblhf.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lblhf = new GridBagConstraints();
		gbc_lblhf.gridwidth = 2;
		gbc_lblhf.anchor = GridBagConstraints.WEST;
		gbc_lblhf.insets = new Insets(0, 0, 5, 5);
		gbc_lblhf.gridx = 1;
		gbc_lblhf.gridy = 13;
		contentPane.add(lblhf, gbc_lblhf);
		
		String[] waterjzs_array=waterjzsList.toArray(new String [waterjzsList.size()+1]);
		waterjzs_array[waterjzsList.size()]="自定义";
		final DefaultComboBoxModel model_4=new DefaultComboBoxModel(waterjzs_array);
		JComboBox comboBox = new JComboBox();
		comboBox.setEditable(true);
		comboBox.setModel(model_4);
		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.gridwidth = 6;
		gbc_comboBox.gridheight = 2;
		gbc_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox.gridx = 4;
		gbc_comboBox.gridy = 13;
		contentPane.add(comboBox, gbc_comboBox);
		
		JLabel lblM = new JLabel(" m");
		lblM.setFont(new Font("Cambria", Font.BOLD, 15));
		GridBagConstraints gbc_lblM = new GridBagConstraints();
		gbc_lblM.anchor = GridBagConstraints.WEST;
		gbc_lblM.gridheight=2;
		gbc_lblM.insets = new Insets(0, 0, 5, 5);
		gbc_lblM.gridx = 10;
		gbc_lblM.gridy = 13;
		contentPane.add(lblM, gbc_lblM);
		
		JLabel lblhf_1 = new JLabel("    土壤水基质势hf：");
		lblhf_1.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_lblhf_1 = new GridBagConstraints();
		gbc_lblhf_1.gridwidth = 2;
		gbc_lblhf_1.anchor = GridBagConstraints.WEST;
		gbc_lblhf_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblhf_1.gridx = 1;
		gbc_lblhf_1.gridy = 14;
		contentPane.add(lblhf_1, gbc_lblhf_1);
		
		
		
		JButton btnNewButton = new JButton("重置");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				textField.setText("");
				txtCm.setText("");
				txtCmcm.setText("");
				txtCm_2.setText("");
				textField.setText("");
				textField_1.setText("");
				txtCmcm_1.setText("");
				model_4.setSelectedItem("请选择以下参数");
				model_2.setSelectedItem("请选择以下参数");
				model_3.setSelectedItem("请选择以下参数");
			}
		});
		
		JButton button = new JButton("提交");
		GridBagConstraints gbc_button = new GridBagConstraints();
		gbc_button.insets = new Insets(0, 0, 5, 5);
		gbc_button.gridx = 13;
		gbc_button.gridy = 15;
		contentPane.add(button, gbc_button);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
					soil.setName((String)textField.getText());                                   /*获取土壤种类*/
					soil.setRange(txtCm.getText());                                              /*获取土壤下边界深度*/
					soil.setFullWater((String)txtCmcm.getText());                                /*获取饱和水量*/
					soil.setWaterTZQX((String)txtCm_2.getText());                                /*获得土壤水分特征曲线拟合系数*/
					soil.setSlxPara_n((String)textField_1.getText());                            /*获得水力学参数n*/
					soil.setRemainWater((String)txtCmcm_1.getText());                            /*获得残余含水量*/
					soil.setSoilWaterjzs((String)model_4.getSelectedItem());                     /*土壤水基质势hf*/
					soil.setDistilledWDDL((String)model_2.getSelectedItem());                       /*获取蒸馏水导电率*/
					soil.setDrySoilJD((String)model_3.getSelectedItem());                              /*获取干土介电常数*/
					soil.setCtrlzone_name(ctrl_model);
					Os=Double.valueOf(soil.getFullWater());
		            Or=Double.valueOf(soil.getRemainWater());
		            On=Double.valueOf(soil.getSlxPara_n());
		            Oa=Double.valueOf(soil.getWaterTZQX());
		            Hf=Double.valueOf(soil.getSoilWaterjzs());
		            Of=Or+(Os-Or)/((1+Math.pow(Oa*Math.pow(-Hf,On),1-1.0/On)));
		            filedWater=Double.toString(Of);
		            soil.setFiled_water(filedWater);
					
		            //String query="insert into soil_para3 value('2','1','1','1','1','1','1','1','1','1','1')";   测试数据库
		            String query = "insert into soil_para3 value("+maxId_3+",'"+soil.getName()+"','"+soil.getCtrlzone_name()+"','"+soil.getRange()+"','"+soil.getWaterTZQX()+"','"+soil.getSlxPara_n()+"','"+soil.getRemainWater()+"','"+soil.getSoilWaterjzs()+"','"+soil.getFullWater()+"','"+soil.getDistilledWDDL()+"','"+soil.getDrySoilJD()+"','"+soil.getFiled_water()+"')";            
		             sql_statement.executeUpdate(query);		            
		             if(!waterjzsList.contains(soil.getSoilWaterjzs())){                            //土壤基质势表更新
		            	 waterjzsList.add(soil.getSoilWaterjzs());
		            	 String query_4="insert into soil_waterjzs value("+waterjzsList.size()+",'"+soil.getSoilWaterjzs()+"')"; 
		            	sql_statement.executeUpdate(query_4);
		            }
		             if(!waterddlList.contains(soil.getDistilledWDDL())){                          //蒸馏水电导率表更新
		            	 waterddlList.add(soil.getDistilledWDDL());
		            	 String  query_7="insert into distilled_wddl value("+waterddlList.size()+",'"+soil.getDistilledWDDL()+"')";
		            	 sql_statement.executeUpdate(query_7);  
		             }
		             if(!dry_soiljdList.contains(soil.getDrySoilJD())){                            //干土电解介电常数表更新
		            	 dry_soiljdList.add(soil.getDrySoilJD());
		            	 String query_8="insert into dry_soiljd value("+dry_soiljdList.size()+",'"+soil.getDrySoilJD()+"')";
		            	 sql_statement.executeUpdate(query_8);
		             }
		             
		             
						sql_statement.close();
			            con.close();
            /** *//************ 对数据库进行相关操作 ************/
		    JOptionPane.showMessageDialog(null,"参数成功导入","提示",JOptionPane.INFORMATION_MESSAGE);
			System.exit(0);
	        } catch (SQLException ex) {
	            //显示数据库连接错误或查询错误
	            System.err.println("SQLException: " + ex.getMessage());
	        }catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} 
			}
		});
		GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton.gridx = 14;
		gbc_btnNewButton.gridy = 15;
		contentPane.add(btnNewButton, gbc_btnNewButton);
	}

	private class SwingAction extends AbstractAction {
		public SwingAction() {
			putValue(NAME, "SwingAction");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
		}
	}
}
